package com.yc.ioc.test.bean2;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Student {
    static Logger log = Logger.getLogger(Student.class);
    String name;
    int age;
    Address address;

    public Student(String name, int age,  Address address) {
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public Student() {
    }
    @Value("chx")
    public void setName(String name) {
        log.debug("用了setName方法"+"name="+name);
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", address=" + address +
                '}';
    }

    @Autowired
    public void setAddress(Address address) {
        this.address = address;
    }

    @Value("18")
    public void setAge(int age) {
        this.age = age;
    }
}
